<?php
    $x = $_REQUEST['x'];  
	$y = $_REQUEST['y'];  
	$dbh = new PDO('sqlite:ball_pos');
	
	$dbh->exec("insert into Ball values(".$x.", ".$y.");");
	
	//get amount of data
	$data = $dbh->prepare("select count(*) from Ball");
	$data->execute();
	$result = $data->fetchAll();
	if($result[0][0]>20)
	{
		$num = $result[0][0]-20;
		$sql = "delete from Ball where rowid in (select rowid from Ball limit 0,".$num.")";
		echo $sql;
		$dbh->exec($sql);
	}
?> 